export default function debounce(fn, delay = 600, runFirstFn = true) {
  let timer = null;

  return function (...rest) {
    // 清除定时器
    clearTimeout(timer);
    if (runFirstFn) {
      fn.apply(this, rest);
      runFirstFn = false;
      return;
    }

    // 设置定时器
    timer = setTimeout(fn.bind(this, ...rest), delay);
  };
}